﻿using System;
using System.Collections.Generic;

using RexToy.UI.WinForm.Controls;
using RexToy.UI.WinForm;

using UnitTest.WinForm.Model;

namespace UnitTest.WinForm.SampleControl
{
    public class TestTreeForm : Form
    {
        [PmlxBoundControl]
        protected TreeView tvc;
        [PmlxBoundControl]
        protected TreeView tvs;

        protected override void OnLoad(EventArgs e)
        {
            Exception inner = new ArgumentException("inner");
            Exception mid = new Exception("mid error", inner);
            Exception ex = new InvalidOperationException("wrap", mid);
            tvs.Bind(ex);

            var cpu = new TreeStruct("CPU");
            cpu.Childs.Add(new TreeStruct("Core 0"));
            cpu.Childs.Add(new TreeStruct("Core 1"));
            var hdd = new TreeStruct("HDD");
            hdd.Childs.Add(new TreeStruct("SSD 128G"));            
            var raid = new TreeStruct("Raid 0");
            raid.Childs.Add(new TreeStruct("HDD 1T"));
            raid.Childs.Add(new TreeStruct("HDD 1T"));
            hdd.Childs.Add(raid);

            var lst = new List<TreeStruct>()
            {
                cpu,
                hdd
            };
            tvc.Bind(lst);
        }
    }
}
